/***************************************************************************
 *   Copyright (C) 2007 by Ziman & Xloverin                                *
 *   ziman@centrum.sk, xloverin@gmail.com                                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#include "preferences.h"

void Preferences::setPrefs(Preferences::Prefs prefs)
{
	pgGeneral->setPrefs(prefs.general);
	pgConnection->setPrefs(prefs.connection);
	pgAppearance->setPrefs(prefs.appearance);
	pgQueries->setPrefs(prefs.queries);
	pgLog->setPrefs(prefs.log);
}

Preferences::Prefs Preferences::prefs()
{
	Prefs prefs;

	prefs.general = pgGeneral->prefs();
	prefs.connection = pgConnection->prefs();
	prefs.appearance = pgAppearance->prefs();
	prefs.queries = pgQueries->prefs();
	prefs.log = pgLog->prefs();

	return prefs;
}

Preferences::Preferences ( QWidget* parent, const NickList &nickList_ )
		: QDialog ( parent), Ui::prefs(), nickList(nickList_)
{
	setupUi ( this );

	// General
	pgGeneral = new PrefsGeneral();
	pages->addWidget(pgGeneral);
	lPages->item(0)->setIcon(QIcon(":/preferences/general.png"));

	// Connection
	pgConnection = new PrefsConnection();
	pages->addWidget(pgConnection);
	lPages->item(1)->setIcon(QIcon(":/preferences/connection.png"));

	// Appearance
	pgAppearance = new PrefsAppearance();
	pages->addWidget(pgAppearance);
	lPages->item(2)->setIcon(QIcon(":/preferences/appearance.png"));

	// Queries
	pgQueries = new PrefsQueries(0, nickList);
	pages->addWidget(pgQueries);
	lPages->item(3)->setIcon(QIcon(":/preferences/queries.png"));

	// Logging
	pgLog = new PrefsLog();
	pages->addWidget(pgLog);
	lPages->item(4)->setIcon(QIcon(":/preferences/log.png"));

	// Nastavime vacsie polozky
	for (int i = 0; i < 5; ++i) {
		lPages->item(i)->setSizeHint(QSize(40, 40));
	}

	// Zafokusujeme prvu polozku
	lPages->setCurrentRow(0);
	lPages->setFocus();

	// Zmazat pagesu, ktoru tam dal designer
	pages->removeWidget(pages->widget(0));

}

Preferences::~Preferences()
{
}

